clear all
lambda = -1+2i;
clf
omega =  (1+i)/sqrt(2);
omega = 0
%q=1.3;

 a = abs(lambda)^2;
 b = real(lambda^2);
 c = abs(omega)^2;
 f=inline(['(x^2+y^2)^2-(1-' num2str(c) ')*(x^2-y^2)^2- 2*' num2str(a-(1-c)*b) '*(x^2-y^2)+' num2str(a^2-4*a*imag(lambda)^2 - (1-c) * b^2) ''  ],'x','y');
 %f= inline(['(x^2+y^2)^2-' num2str(a^2) ' -2*' num2str(a) '*(x^2-y^2-' num2str(b) ' ) - (1-' num2str(c) ')*(x^2-y^2-' num2str(b) ' )^2'],'x','y')
% f=inline(['(x^2+y^2)^2-2*' num2str(b) '*(x^2-y^2) +' num2str(b^2-4*imag(lambda)^2*q+4*real(lambda)^2*imag(lambda)^2 ) ''],'x','y');
 f1 = inline(['x^2-y^2-' num2str(b) ''],'x','y'); % ok
 f2 = inline(['-4*x^2*y^2 +4*' num2str(imag(lambda)^4+10) '+4*(x^2-y^2) *' num2str(imag(lambda)^2) ''],'x','y');
 %f3 = inline([' (x^2-y^2 -' num2str(b) ')^2-(x^2+y^2)^2+' num2str(a^2) '+2*(x^2-y^2-' num2str(b) ')*' num2str(a) '-' num2str(q12^2) ''])%diskriminant
 rangexy = [-6 6 -6 6];
 N=1000;
 %[x2,y2,fvalues]=implot(f3,rangexy,N,'k');


 [x,y,fvalues]=implot(f,rangexy,N,'b');
 hold on;
 [x1,y1,fvalues]= implot(f1,rangexy,N,'b');

 x_imag = linspace(rangexy(1),rangexy(2),N);
 y_imag = repmat(imag(lambda),1,N);

  [X0,Y0] = intersections(x,y,x1,y1,1);
  
indexy = find(X0<0);

vx =  [ rangexy(1) X0(indexy(1)) rangexy(1) X0(indexy(2))];
vy =  [ Y0(indexy(1)) Y0(indexy(1)) Y0(indexy(2)) Y0(indexy(2))];    
indexy_toricu = find(x < max (X0(indexy)));
vtx = x(indexy_toricu);
vty = y(indexy_toricu);

xv = [vx vtx];
yv = [vy vty];
xy = [xv; yv];
tt = sortrows(xy',2)';
fill([ rangexy(1) tt(1,:) rangexy(1)],[min(Y0(indexy)) tt(2,:) max(Y0(indexy))],[0.9 0.9 0.9])
 plot(x_imag,y_imag,'r-','LineWidth',2);
% plot(real(lambda),imag(lambda),'k+','Markersize',10,'LineWidth',1)
 plot([min(abs(rangexy)) -min(abs(rangexy))],[min(abs(rangexy)) -min(abs(rangexy))],'k--','LineWidth',1);
 plot(linspace(rangexy(1),rangexy(2),N),-repmat(imag(lambda),1,N),'r-','LineWidth',2);
 plot([-min(abs(rangexy)) min(abs(rangexy))],[min(abs(rangexy)) -min(abs(rangexy))],'k--','LineWidth',1)
 arrow([0 0],[real(lambda) imag(lambda)])
arrow([0 0],[real(lambda) -imag(lambda)])
arrow([0 rangexy(3)],[0 rangexy(4)],'LineStyle','-','BaseAngle',45)
arrow([ rangexy(1) 0],[ rangexy(2) 0],'LineStyle','-','BaseAngle',45)  
% return



implot(f,rangexy,N,'b');

implot(f1,rangexy,N,'b');

%plot(rangexy(1:2),[0 0],'k--');
%plot([0 0],rangexy(3:4),'k--');
arrow([0 rangexy(3)],[0 rangexy(4)],'LineStyle','--','BaseAngle',45)
arrow([ rangexy(1) 0],[ rangexy(2) 0],'LineStyle','--','BaseAngle',45)  
arrow([0 0],[real(lambda) imag(lambda)])
arrow([0 0],[real(lambda) -imag(lambda)])

% >> plot(1:10)
% >> legend('$\overline{W}$')
% >> h = legend;
% >> set(h, 'interpreter', 'latex')
 h = text;
set(h, 'interpreter', 'latex')
 text([real(lambda)],[ -imag(lambda)-.5],'$\overline{\lambda}$','interpreter','latex','FontSize',16);
text([real(lambda)],[ imag(lambda)+.5],'$\lambda$','interpreter','latex','FontSize',16)
text(rangexy(2)-1.25,.5,'R e$s$','interpreter','latex','FontSize',16)
text(.25,rangexy(4)-.5,'$\mbox{Im}s$','interpreter','latex','FontSize',16)
box off
axis off
 % grid on
  %legend('rovnice 3','rovnice4','rovnice 2','pol','rovnice 1')
 